This is for an old version of MySQL but it may work on your current version
Handling MySQL users and permissions
We are going to grant permissions for a given database to a specific user on a specific host. In the example we grant usage to localhost and a hostname to allow external access.
grant all privileges on dbname.* to 'dbname'@'localhost' identified by 'password';
grant all privileges on dbname.* to 'dbname'@'<FQN_hostname> ' identified by 'password';